package flower.home.common.poi;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description
 * @Author gbzdyf@126.com
 * @Date 2021/6/17 上午9:50
 */
public enum DataTempEnum {

    INVOICE_ORDER_NO("订单编号", "orderNo", false, ""),
    CORP_IDENTITY_ID("生成时间", "createdTime", false, ""),
    SALE_TAX_NUM("失效时间", "expireTIme", false, ""),
    SALE_NAME("含税金额", "taxAmount", false, ""),
    SALE_PHONE("状态", "status", false, ""),
    SALE_ADDRESS("发票抬头", "buyerName", false, ""),
    SALE_BANK_ACCOUNT("发票代码/号码", "invoiceCodeAndNum", false, ""),
    BUYER_NAME("二维码地址", "ewmUrl", false, ""),
    BUYER_TAX_NUM("商品名称", "goodsName", false, ""),
    BUYER_ADDRESS("规格型号", "unit", false, ""),
    BUYER_TEL_PHONE("含税单价", "taxPrice", false, ""),
    BUYER_BANK_ACCOUNT("数量", "num", false, ""),
    BUYER_SEND_PHONE("金额", "amount", false, ""),
    BUYER_SEND_EMAIL("税率", "taxRate", false, ""),
    INVOICE_LINE("扣除额", "deductAmount", false, ""),
    INVOICE_NATURE("折扣金额", "discountAmount", false, "")
    ;

    /**
     * 校验自动MAP
     */
    private static final Map<Integer, DataTempEnum> verifyColumnMap;

    /**
     * 全部字段
     */
    private static final Map<Integer, DataTempEnum> allColumnMap;

    /**
     * 总字段长度
     */
    private static final Integer columnLength;

    static {
        DataTempEnum[] values = values();
        columnLength = values.length;
        Map<Integer, DataTempEnum> mp = new HashMap<>();
        Map<Integer, DataTempEnum> allMp = new HashMap<>();
        for (DataTempEnum value : values) {
            if (value.isVerifyFlag()) {
                mp.put(value.ordinal(), value);
            }
            allMp.put(value.ordinal(), value);
        }
        verifyColumnMap = Collections.unmodifiableMap(mp);
        allColumnMap = Collections.unmodifiableMap(allMp);
    }

    /**
     * 模版抬头
     */
    private final String templateTitle;

    /**
     * 属性字段
     */
    private final String columnAttribute;

    /**
     * 是否校验
     */
    private final boolean verifyFlag;

    /**
     * 默认值
     */
    private final String excelDefaultValue;

    DataTempEnum(String templateTitle,  String columnAttribute, boolean verifyFlag, String excelDefaultValue) {
        this.templateTitle = templateTitle;
        this.columnAttribute = columnAttribute;
        this.verifyFlag = verifyFlag;
        this.excelDefaultValue = excelDefaultValue;
    }

    public String getTemplateTitle() {
        return templateTitle;
    }

    public String getColumnAttribute() {
        return columnAttribute;
    }

    public boolean isVerifyFlag() {
        return verifyFlag;
    }

    public static Integer getEnumsColumnLength() {
        return columnLength;
    }

    public static Map<Integer, DataTempEnum> getVerifyColumnMap() {
        return verifyColumnMap;
    }

    public static Map<Integer, DataTempEnum>     getAllColumnMap() {
        return allColumnMap;
    }

    public String getExcelDefaultValue() {
        return excelDefaultValue;
    }
}
